package com.crm.controller;

import cn.hutool.core.util.ObjectUtil;
import com.crm.commons.exception.BusinessException;
import com.crm.commons.exception.enumVo.BussinessExceptionEnum;
import com.crm.entity.CrmUser;
import com.crm.vo.MySecurityUser;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author junxian.dou
 * @Package：com.crm.controller
 * @Project：springboot-crm
 * @name：BaseController
 * @Date：2024/11/28 14:02
 * @Filename：BaseController
 * @verson 1.0.0
 * @desc
 */
public class BaseController {

    public CrmUser getUserInfo(){
        CrmUser principal = (CrmUser)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        if (ObjectUtil.isNull(principal)) {
            throw new BusinessException(BussinessExceptionEnum.USER_NOT_EXISTS);
        }
        principal.setLoginPwd(null);
        return  principal;
    }
}
